import React, { useState, useLayoutEffect } from 'react'

function App() {
  const [ str, setStr ] = useState('')
  useLayoutEffect(() => {
    const test = document.getElementById('test')
    setStr(test.innerHTML)
  }, [])
  return (
    <div>
      <div id="test">测试</div>
      <div>{ str }</div>
    </div>
  )
}

export default App
